//
//  MAPYShadowSocksManager.h
//  Mars Proxy
//
//  Created by PowerfullClean on 2023/10/17.
//

#import <Foundation/Foundation.h>

NS_ASSUME_NONNULL_BEGIN

@interface MAPYShadowSocksManager : NSObject

extern const int kShadowSocksLocalPort;

typedef NS_ENUM(NSInteger, ErrorCode) {
    noError = 0,
    undefinedError = 1,
    vpnPermissionNotGranted = 2,
    invalidServerCredentials = 3,
    udpRelayNotEnabled = 4,
    serverUnreachable = 5,
    vpnStartFailure = 6,
    illegalServerConfiguration = 7,
    ShadowSocksStartFailure = 8,
    configureSystemProxyFailure = 9,
    noAdminPermissions = 10
};

@property (nonatomic) NSDictionary *config;
@property (nonatomic) int localSSPort;
@property (nonatomic) int localSSUdpPort;

/**
 * Initializes the object with a GreenShadowSocks server configuration, |config|.
 */
- (id)init:(NSDictionary *)config;

/**
 * Starts ss-local on a separate thread with the configuration supplied in the constructor.
 * If |checkConnectivity| is true, verifies that the server credentials are valid and that
 * the remote supports UDP forwarding, calling |completion| with the result.
 */
- (void)startWithConnectivityChecks:(bool)checkConnectivity
                         completion:(void (^)(ErrorCode))completion;

/**
 * Stops the thread running ss-local. Calls |completion| with the success of the operation.
 */
- (void)stop:(void (^)(ErrorCode))completion;


- (void)isReachable:(void (^)(ErrorCode))completion;

- (BOOL)startCheckConnectivity:(void (^)(BOOL))completion;

@end

NS_ASSUME_NONNULL_END
